import { history } from 'umi'
import { connect } from 'dva'

const Count = (props: any) => {
  const goIndex = () => [
    history.push('/')
  ]
  return (
    <>
      <div>
        <h1>我是Count</h1>
        <button onClick={goIndex}>GO Index</button>
        <p>男女总人数为：{props.count}</p>
        <button onClick={() => { props.clear() }}>清零</button>
      </div>
    </>
  )
}

const actionCreator = {
  clear: () => ({ type: 'store/clear' })
}

export default connect((state: any) => ({ count: state.store.count }), actionCreator)(Count)